import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  ManyToMany,
  JoinTable,
} from "typeorm";
import { Role } from "./Role";

@Entity()
export class User {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    length: 50,
  })
  username: string;

  @ManyToMany(() => Role, (role) => role.users, {
    cascade: true,
    onDelete: "CASCADE",
  })
  @JoinTable()
  roles: Role[];
}
